import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useAuthStore = defineStore('auth', () => {
  const isAuthenticated = ref(false)
  const user = ref<string | null>(null)

  async function login(username: string, password: string) {
    // TODO: 实现登录逻辑
    isAuthenticated.value = true
    user.value = username
  }

  function logout() {
    isAuthenticated.value = false
    user.value = null
  }

  async function initialize() {
    // TODO: 实现初始化检查（例如检查本地token）
  }

  return {
    isAuthenticated,
    user,
    login,
    logout,
    initialize,
  }
})
